//
//  YGJNavigationController.m
//  ygj-customer-iOS
//
//  Created by apple on 16/11/11.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "YGJNavigationController.h"
#import "UIColor+Theme.h"
#import "UIColor+Hex.h"
#import "UIBarButtonItem+Extension.h"

@interface YGJNavigationController ()

@end

@implementation YGJNavigationController




- (void)viewDidLoad {
    [super viewDidLoad];

    [self setBarApperance];
    
    
}

#pragma mark 设置导航栏样式
-(void) setBarApperance {
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithHexString:@"#0093ff"]];
    
    self.navigationBar.tintColor =[UIColor whiteColor];
    [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
}
    
-(void) setLeftBtnWithName:(NSString *)btnName WithBtnImage:(NSString *)imageName WithBtnTag:(NSInteger )index{
    if (btnName != nil && imageName != nil) {
        
    }

}

-(void) setRightBtnWithName:(NSString *)btnName WithBtnImage:(NSString *)imageName WithBtnTag:(NSInteger )index{
    if (btnName != nil && imageName != nil) {
        
    }
    
}
    
-(void) leftAction:(NSInteger *) btnTag{
    
    NSLog(@"点击按钮tag：%ld",(long)btnTag);
}
    
    
/**
 *  重写这个方法目的：能够拦截所有push进来的控制器
 *
 *  @param viewController 即将push进来的控制器
 */
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    
//    if (self.viewControllers.count > 0) { // 这时push进来的控制器viewController，不是第一个子控制器（不是根控制器）
        /* 自动显示和隐藏tabbar */
//        viewController.hidesBottomBarWhenPushed = YES;
//        
//        /* 设置导航栏上面的内容 */
//        // 设置左边的返回按钮
//        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(goback) image:@"navBackBtn" highImage:@"navBackBtn"];
//        
//        // 设置右边的更多按钮
//        viewController.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(more) image:@"navigationbar_more" highImage:@"navigationbar_more_highlighted"];
//    }
//    
    [super pushViewController:viewController animated:animated];
}

- (void)goback
{
    // 因为self本来就是一个导航控制器，self.navigationController这里是nil的
    [self popViewControllerAnimated:YES];
}

- (void)more
{
    [self popToRootViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
